package pl.lodz.p.kipme.entities;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

@Table(name = "PRODUCT_ENTITIES", uniqueConstraints = { @UniqueConstraint(columnNames = "PRODUCT_CODE") })
@Entity
public class ProductEntity {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    
    @Column(name = "PRODUCT_CODE", unique = true)
    private String productCode;
    private String name;
    private float price;
    private String describe;
    private int amount;
    @ManyToOne(cascade = CascadeType.PERSIST, targetEntity = CategoryEntity.class)
    @JoinColumn(name="CATEGORY_CODE")
    private CategoryEntity category;
    @ManyToOne(cascade = CascadeType.PERSIST, targetEntity = TypeEntity.class)
    @JoinColumn(name="TYPE_CODE")
    private TypeEntity type;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getProductCode() {
        return productCode;
    }

    public void setProductCode(String productCode) {
        this.productCode = productCode;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public float getPrice() {
        return price;
    }

    public void setPrice(float price) {
        this.price = price;
    }

    public String getDescribe() {
        return describe;
    }

    public void setDescribe(String describe) {
        this.describe = describe;
    }

    public int getAmount() {
        return amount;
    }

    public void setAmount(int amount) {
        this.amount = amount;
    }

    public CategoryEntity getCategory() {
        return category;
    }

    public void setCategory(CategoryEntity category) {
        this.category = category;
    }

    public TypeEntity getType() {
        return type;
    }

    public void setType(TypeEntity type) {
        this.type = type;
    }
}
